#include <stdio.h>
#include <string.h>
#include <stdlib.h>


void main ()
{
	int a[100000], i, N, step, st, ingame, win;
	printf("Number of players:");
	scanf("%d", &N);
	printf("\nstep: ");
	scanf("%d", &step);

  for(i=0; i<N; i++)
  {
	  a[i]=i+1;
  }
  ingame=N;
  i=0;
  st=1;
 while (ingame>0)
 {
	if (i<=N-1)
	{
		if (a[i]!=0)
		{
			if (st==1)
			{
			printf("out:%d\n", i+1);
			win=a[i];
			a[i]=0;
			
			ingame=ingame-1;
			//i=i+1;
			st=step;
			}
			else 
			{
				i=i+1;
				st=st-1;
			}
			
		}
		else i=i+1;
	}
	else i=0;
 }


	
	 
		 printf("\nWinner!:%d\n", win);
	 

  system("PAUSE");
}